﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using CUREBusinessLogicLayer;
using CURE.Handler;

/*************************************************************************************

     * 作   者： 张 颖
  
*************************************************************************************/
namespace CURE.SystemManagement
{
    /// <summary>
    /// 系统管理 - 模块管理
    /// </summary>
    public partial class ModuleManagement : System.Web.UI.Page
    {
        ModulBll moduBll = new ModulBll();
        protected void Page_Load(object sender, EventArgs e)
        {
            JudgeAuthority ja = new JudgeAuthority();
            if (!ja.JudgeUserAuthorityByGroupId("SystemManagement/ModuleManagement.aspx"))
            {
                Response.Write("<script language=javascript>top.location.href='../../Login.aspx';</script>");
                Response.End();
            }
        }

        public string getTree()
        {
            string html = "";
            html = "<ul class=\"tree treeFolder expand\">";
            DataTable fathetlist = moduBll.GetModuData();
            if (fathetlist != null && fathetlist.Rows.Count > 0)
            {
                for (int i = 0; i < fathetlist.Rows.Count; i++)
                {
                    string columnId = "";
                    if (fathetlist.Rows[i]["action_columnid"] != null)
                    {
                        columnId = fathetlist.Rows[i]["action_columnid"].ToString().Trim();
                        html += "<li><a href=\"SystemManagement/ModuleList.aspx?type=father&action=" + fathetlist.Rows[i]["action_columnid"].ToString().Trim() + "\" target=\"ajax\" rel=\"Box1\">" + fathetlist.Rows[i]["action_columnname"].ToString().Trim() + "</a>";
                    }
                    string temp = string.Empty;
                    DataTable childlist = moduBll.GetChildModuData(columnId);
                    if (childlist != null && childlist.Rows.Count > 0)
                    {
                        temp = "<ul>";

                        for (int j = 0; j < childlist.Rows.Count; j++)
                        {
                            if (childlist.Rows[j]["action_name"].ToString() != "")
                            {
                                temp += "<li><a href=\"SystemManagement/ModuleList.aspx?type=child&action=" + childlist.Rows[j]["action"].ToString().Trim() + "\" target=\"ajax\" rel=\"Box1\">" + childlist.Rows[j]["action_name"].ToString().Trim() + "</a></li>";
                            }
                        }
                        temp += "</ul>";

                    }
                    if (temp != "")
                    {
                        html += temp;
                    }
                    html += "</li>";

                }
            }
            html += "</ul>";
            return html;
        }
    }
}